<?php

abstract class Trace {
    private static $content = array();
    private static $trace_on = false;


    public static function setTracing($state) {
        self::$trace_on = $state;
    }

    static function rec($text) {
        if (!self::$trace_on) return;
        self::$content[] = $text;
    }

    static function save($file) {
        if (!count(self::$content)) return 0;
        $content = date('Y-m-d H:i:s').
                "\n----------------------------------".
                "\n\n".
                join("\n",self::$content).
                "\n----------------------------------".
                "\n\n\n";
        return @file_put_contents($file, $content, FILE_APPEND);
    }
}
?>